package cn.mesmile.auth.service.impl;

import cn.dev33.satoken.secure.SaSecureUtil;
import cn.dev33.satoken.stp.SaTokenInfo;
import cn.dev33.satoken.stp.StpUtil;
import cn.mesmile.auth.service.UmsAdminService;
import org.springframework.stereotype.Service;

/**
 * @author zb
 * @date 2021/8/19 10:25
 * @Description
 */
@Service
public class UmsAdminServiceImpl implements UmsAdminService {

    @Override
    public SaTokenInfo login(String username, String password) {
        SaTokenInfo saTokenInfo = null;
//        AdminUser adminUser = getAdminByUsername(username);
//        if (adminUser == null) {
//            return null;
//        }
//        if (!SaSecureUtil.sha256(password).equals(adminUser.getPassword())) {
//            return null;
//        }
        // 密码校验成功后登录，一行代码实现登录
        StpUtil.login(username);
        // 获取当前登录用户Token信息
        saTokenInfo = StpUtil.getTokenInfo();
        return saTokenInfo;
    }
}
